/* Frappe Gantt 基础样式 */
:root {
  --g-arrow-color: #1f2937;
  --g-bar-color: #fff;
  --g-bar-border: #fff;
  --g-tick-color-thick: #ededed;
  --g-tick-color: #f3f3f3;
  --g-actions-background: #f3f3f3;
  --g-border-color: #ebeff2;
  --g-text-muted: #7c7c7c;
  --g-text-light: #fff;
  --g-text-dark: #171717;
  --g-progress-color: #dbdbdb;
  --g-handle-color: #37352f;
  --g-weekend-label-color: #dcdce4;
  --g-expected-progress: #c4c4e9;
  --g-header-background: #fff;
  --g-row-color: #fdfdfd;
  --g-row-border-color: #c7c7c7;
  --g-today-highlight: #37352f;
  --g-popup-actions: #ebeff2;
  --g-weekend-highlight-color: #f7f7f7;
}

.gantt-container {
  line-height: 14.5px;
  position: relative;
  overflow: auto;
  font-size: 12px;
  height: var(--gv-grid-height);
  width: 100%;
  border-radius: 8px;
}

.gantt-container .popup-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  background: #fff;
  box-shadow: 0 10px 24px -3px rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 5px;
  width: max-content;
  z-index: 1000;
}

.gantt-container .popup-wrapper .title {
  margin-bottom: 2px;
  color: var(--g-text-dark);
  font-size: 0.85rem;
  font-weight: 650;
  line-height: 15px;
}

.gantt-container .popup-wrapper .subtitle {
  color: var(--g-text-dark);
  font-size: 0.8rem;
  margin-bottom: 5px;
}

.gantt-container .popup-wrapper .details {
  color: var(--g-text-muted);
  font-size: 0.7rem;
}

.gantt-container .grid-header {
  height: calc(var(--gv-lower-header-height) + var(--gv-upper-header-height) + 10px);
  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  position: sticky;
  top: 0;
  left: 0;
  border-bottom: 2px solid #e5e7eb;
  z-index: 1000;
}

.dark .gantt-container .grid-header {
  background: linear-gradient(180deg, #111827 0%, #0f1419 100%);
  border-bottom-color: #374151;
}

.gantt-container .lower-text,
.gantt-container .upper-text {
  text-anchor: middle;
}

.gantt-container .upper-header {
  height: var(--gv-upper-header-height);
}

.gantt-container .lower-header {
  height: var(--gv-lower-header-height);
}

.gantt-container .lower-text {
  font-size: 12px !important;
  position: absolute;
  width: calc(var(--gv-column-width) * 0.8);
  height: calc(var(--gv-lower-header-height) * 0.8);
  margin: 0 calc(var(--gv-column-width) * 0.1);
  align-content: center;
  text-align: center;
  color: #9ca3af !important;
  font-weight: 500 !important;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif !important;
}

.gantt-container .upper-text {
  position: absolute;
  width: fit-content;
  font-weight: 700 !important;
  font-size: 14px !important;
  color: #1f2937 !important;
  height: calc(var(--gv-lower-header-height) * 0.66);
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif !important;
}

.dark .gantt-container .lower-text {
  color: #6b7280 !important;
}

.dark .gantt-container .upper-text {
  color: #e5e7eb !important;
}

.gantt-container .current-highlight {
  position: absolute;
  background: var(--g-today-highlight);
  width: 1px;
  z-index: 999;
}

.gantt {
  user-select: none;
  -webkit-user-select: none;
  position: absolute;
}

.gantt .grid-background {
  fill: none;
}

.gantt .grid-row {
  fill: var(--g-row-color);
}

.gantt .row-line {
  stroke: var(--g-border-color);
}

.gantt .tick {
  stroke: var(--g-tick-color);
  stroke-width: 0.4;
}

.gantt .tick.thick {
  stroke: var(--g-tick-color-thick);
  stroke-width: 0.7;
}

.gantt .arrow {
  fill: none;
  stroke: var(--g-arrow-color);
  stroke-width: 1.5;
}

.gantt .bar-wrapper .bar {
  fill: var(--g-bar-color);
  stroke: var(--g-bar-border);
  stroke-width: 0;
  transition: stroke-width 0.3s ease;
}

.gantt .bar-progress {
  fill: var(--g-progress-color);
  border-radius: 4px;
}

.gantt .bar-label {
  fill: #ffffff !important;
  dominant-baseline: central;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.2);
  letter-spacing: 0em;
  paint-order: stroke fill;
}

.gantt .handle {
  fill: rgba(255, 255, 255, 0.9) !important;
  stroke: rgba(59, 130, 246, 0.5);
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: ew-resize;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.gantt .bar-wrapper:hover .handle {
  opacity: 1;
}

.gantt .handle.active,
.gantt .handle.visible {
  cursor: ew-resize;
  opacity: 1;
  fill: #ffffff !important;
}

.gantt .bar-wrapper {
  cursor: pointer;
}

.gantt .bar-wrapper .bar {
  outline: 1px solid var(--g-row-border-color);
  border-radius: 3px;
}

.gantt .bar-wrapper:hover .bar {
  transition: transform 0.3s ease;
  filter: brightness(1.05);
  stroke-width: 2 !important;
}

/* 优化网格线 */
.gantt .grid-row {
  fill: #ffffff;
  transition: fill 0.2s ease;
}

.gantt .grid-row:nth-of-type(even) {
  fill: #f9fafb;
}

.gantt .row-line {
  stroke: #e5e7eb !important;
  stroke-width: 0.5 !important;
  opacity: 0.8;
}

.gantt .tick {
  stroke: #f3f4f6 !important;
  stroke-width: 0.5 !important;
  opacity: 0.6;
}

.gantt .tick.thick {
  stroke: #d1d5db !important;
  stroke-width: 1.5 !important;
  opacity: 1;
}

/* 今日高亮 */
.gantt .current-highlight {
  fill: #dbeafe !important;
  opacity: 0.8 !important;
}

.gantt .today-highlight {
  fill: #bfdbfe !important;
  opacity: 0.5 !important;
}

/* 暗色模式优化 */
.dark .gantt .grid-row {
  fill: #0f1419;
}

.dark .gantt .grid-row:nth-of-type(even) {
  fill: #1a1f2e;
}

.dark .gantt .row-line {
  stroke: #374151 !important;
  opacity: 0.6;
}

.dark .gantt .tick {
  stroke: #374151 !important;
  opacity: 0.4;
}

.dark .gantt .tick.thick {
  stroke: #4b5563 !important;
  opacity: 1;
}

.dark .gantt .current-highlight {
  fill: #1e3a8a !important;
  opacity: 0.4 !important;
}

.dark .gantt .today-highlight {
  fill: #1e40af !important;
  opacity: 0.3 !important;
}

.dark .gantt .lower-text,
.dark .gantt .upper-text {
  fill: #9ca3af !important;
}

.dark .gantt-container .grid-header {
  background-color: #111827;
  border-bottom-color: #374151;
}

.dark .gantt .current-highlight {
  background: #3b82f6 !important;
  opacity: 0.2 !important;
}

/* 自定义容器样式 */
.frappe-gantt-container {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  min-height: 400px !important;
  border-radius: 8px;
}

.frappe-gantt-container svg {
  width: 100% !important;
  height: auto !important;
  min-height: 350px !important;
}

.frappe-gantt-container .gantt {
  min-height: 350px !important;
}

/* 自定义甘特图样式 */
.gantt {
  font-family: inherit;
}

/* 重要：覆盖默认任务条样式 */
.gantt .bar-wrapper .bar {
  fill: #3b82f6 !important;
  stroke: none !important;
  stroke-width: 0 !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  rx: 4 !important;
  ry: 4 !important;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

.gantt .bar-wrapper:hover .bar {
  filter: brightness(1.05) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.15));
  cursor: pointer;
}

.gantt .bar-wrapper .bar-progress {
  fill: rgba(0, 0, 0, 0.15) !important;
  rx: 4 !important;
  ry: 4 !important;
}

.gantt .bar-invalid {
  fill: #ef4444;
  stroke: #dc2626;
}

.gantt .bar-label {
  fill: #fff;
  font-size: 12px;
  font-weight: 500;
}

.gantt .handle {
  fill: #fff;
  stroke: #2563eb;
  stroke-width: 2;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gantt .bar-wrapper:hover .handle {
  opacity: 1;
}

.gantt .lower-text,
.gantt .upper-text {
  fill: #6b7280;
  font-size: 11px;
}

.gantt .grid-header {
  fill: #f9fafb;
  stroke: #e5e7eb;
  stroke-width: 1;
}

.gantt .grid-row {
  fill: #fff;
}

.gantt .grid-row:nth-child(even) {
  fill: #f9fafb;
}

.gantt .row-line {
  stroke: #e5e7eb;
  stroke-width: 1;
}

.gantt .tick {
  stroke: #e5e7eb;
  stroke-width: 0.5;
}

.gantt .tick.thick {
  stroke: #d1d5db;
  stroke-width: 1;
}

.gantt .today-highlight {
  fill: #dbeafe;
  opacity: 0.5;
}

/* 现代化弹出框样式 */
.gantt-popup-modern {
  padding: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow:
    0 10px 25px -5px rgba(0, 0, 0, 0.1),
    0 8px 10px -6px rgba(0, 0, 0, 0.1);
  min-width: 300px;
  max-width: 350px;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.gantt-popup-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  text-align: center;
}

.gantt-popup-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  text-align: center;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
}

.gantt-popup-body {
  padding: 16px 20px 18px;
}

.popup-info-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.popup-info-item:last-child {
  margin-bottom: 0;
}

.popup-info-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.popup-info-text {
  flex: 1;
}

.popup-info-label {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
}

.popup-info-value {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  line-height: 1.4;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
}

.popup-progress-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.popup-progress-bar {
  flex: 1;
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.popup-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.popup-progress-text {
  font-size: 13px;
  font-weight: 700;
  color: #3b82f6;
  min-width: 40px;
  text-align: right;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
}

/* 暗色模式支持 */
.dark .gantt .grid-header {
  fill: #1f2937;
  stroke: #374151;
}

.dark .gantt .grid-row {
  fill: #111827;
}

.dark .gantt .grid-row:nth-child(even) {
  fill: #1f2937;
}

.dark .gantt .row-line {
  stroke: #374151;
}

.dark .gantt .tick {
  stroke: #374151;
}

.dark .gantt .tick.thick {
  stroke: #4b5563;
}

.dark .gantt .lower-text,
.dark .gantt .upper-text {
  fill: #9ca3af;
}

.dark .gantt .today-highlight {
  fill: #1e3a8a;
  opacity: 0.3;
}

.dark .gantt-popup-modern {
  background: #1f2937;
  border-color: #374151;
}

.dark .gantt-popup-header {
  background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
}

.dark .gantt-popup-title {
  color: #ffffff;
}

.dark .popup-info-label {
  color: #9ca3af;
}

.dark .popup-info-value {
  color: #f3f4f6;
}

.dark .popup-progress-bar {
  background: #374151;
}

.dark .popup-progress-text {
  color: #60a5fa;
}

/* 自定义任务颜色类 - 使用!important确保优先级 */
.gantt .bar-wrapper.task-3b82f6 .bar {
  fill: #3b82f6 !important;
  stroke: none !important;
}

.gantt .bar-wrapper.task-10b981 .bar {
  fill: #10b981 !important;
  stroke: none !important;
}

.gantt .bar-wrapper.task-f59e0b .bar {
  fill: #f59e0b !important;
  stroke: none !important;
}

.gantt .bar-wrapper.task-ef4444 .bar {
  fill: #ef4444 !important;
  stroke: none !important;
}

.gantt .bar-wrapper.task-8b5cf6 .bar {
  fill: #8b5cf6 !important;
  stroke: none !important;
}

.gantt .bar-wrapper.task-ec4899 .bar {
  fill: #ec4899 !important;
  stroke: none !important;
}

.gantt .bar-wrapper.task-06b6d4 .bar {
  fill: #06b6d4 !important;
  stroke: none !important;
}

.gantt .bar-wrapper.task-84cc16 .bar {
  fill: #84cc16 !important;
  stroke: none !important;
}

/* 确保进度条也有对应颜色 */
.gantt .bar-wrapper.task-3b82f6 .bar-progress {
  fill: rgba(30, 64, 175, 0.6) !important;
}

.gantt .bar-wrapper.task-10b981 .bar-progress {
  fill: rgba(4, 120, 87, 0.6) !important;
}

.gantt .bar-wrapper.task-f59e0b .bar-progress {
  fill: rgba(180, 83, 9, 0.6) !important;
}

.gantt .bar-wrapper.task-ef4444 .bar-progress {
  fill: rgba(185, 28, 28, 0.6) !important;
}

.gantt .bar-wrapper.task-8b5cf6 .bar-progress {
  fill: rgba(109, 40, 217, 0.6) !important;
}

.gantt .bar-wrapper.task-ec4899 .bar-progress {
  fill: rgba(190, 24, 93, 0.6) !important;
}

.gantt .bar-wrapper.task-06b6d4 .bar-progress {
  fill: rgba(14, 116, 144, 0.6) !important;
}

.gantt .bar-wrapper.task-84cc16 .bar-progress {
  fill: rgba(77, 124, 15, 0.6) !important;
}

/* 依赖箭头样式优化 */
.gantt .arrow {
  fill: none !important;
  stroke: #94a3b8 !important;
  stroke-width: 2 !important;
  opacity: 1;
  transition: all 0.2s ease;
}

.gantt .arrow:hover {
  stroke: #3b82f6 !important;
  stroke-width: 2.5 !important;
  opacity: 1;
}

/* 箭头头部 */
.gantt marker {
  fill: #94a3b8 !important;
}

.dark .gantt .arrow {
  stroke: #64748b !important;
}

.dark .gantt .arrow:hover {
  stroke: #60a5fa !important;
}

.dark .gantt marker {
  fill: #64748b !important;
}
